from sqlalchemy import Column, BigInteger, String, DateTime, ForeignKey
from sqlalchemy.sql import func
from app.db.database import Base

class User(Base):
    __tablename__ = "user"
    id = Column(BigInteger, primary_key=True, autoincrement=True, index=True)
    username   = Column(String(32), unique=True, nullable=False)
    password   = Column(String(60), nullable=False)
    nickname   = Column(String(32))
    phone      = Column(String(20))
    user_type  = Column(String(16), ForeignKey("dict.item_code"), nullable=False)
    gender     = Column(String(1), ForeignKey("dict.item_code"))
    created_at = Column(DateTime, server_default=func.now())
    updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())